#pragma once
//============================================================================
// Copyright (C) 2009-2013 Brett R. Jones 
// All Rights Reserved
//
// You may redistribute and/or modify for non commercial and commercial uses 
// provided this copyright notice remains in place and is not modified
//
// This code is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// brettjones1900@gmail.com
// http://www.p2panarchy.com
//============================================================================

#include <string>
#include <vector>
#include <VxUtilLib/VxDefs.h>
#include "SharedFileInfo.h"

class VxThread;

class SharedFileFinder
{
public:
	bool m_bAbort;

	void Abort( void ){ m_bAbort = TRUE; }

	//find files matching the extension (file type) list
	RCODE FindFilesByExtension(	std::string					csPath,								//start path to search in
								std::vector<std::string> &	acsExtensionList,					//Extensions of files to find
								std::vector<SharedFileInfo> &	aoFileList,							//return FileInfo in array
								bool						bRecurse = FALSE,					//recurse subdirectories if TRUE
								bool						bUseFilterListToExclude = FALSE		//if TRUE dont return files matching filter else return files that do
								);
	//find files matching the extension (file type) list
	RCODE FindFilesByName(		VxThread *						poThread,
								std::string						csPath,								//start path to search in
								std::vector<std::string> &		acsWildNameList,					//Wildcard Name match strings
								std::vector<SharedFileInfo> &	aoFileList,							//return FileInfo in array
								bool							bRecurse = FALSE,					//recurse subdirectories if TRUE
								bool							bUseFilterListToExclude = FALSE		//if TRUE dont return files matching filter else return files that do
								);
protected:
	bool HasSameExtension( std::string csCurrentNode,
							std::vector<std::string> &acsExtensionList );
	bool HasMatchingName( std::string csCurrentNode,
							std::vector<std::string> &acsWildNameList );
};

//! search for files
RCODE FindSharedFilesByExtension(	std::string					csPath,							//start path to search in
									std::vector<std::string>&	acsExtensionList,				//Extensions ( file extentions )
									std::vector<SharedFileInfo>&	aoFileList,						//return FileInfo in array
									bool						bRecurse = FALSE,				//recurse subdirectories if TRUE
									bool						bUseFilterListToExclude = FALSE	//if TRUE dont return files matching filter else return files that do
									);

RCODE FindSharedFilesByName(	VxThread *						poThread,
								std::string						csPath,							//start path to search in
								std::vector<std::string>&		acsWildNameList,				//filters
								std::vector<SharedFileInfo>&	aoFileList,						//return FileInfo in array
								bool							bRecurse = FALSE,				//recurse subdirectories if TRUE
								bool							bUseFilterListToExclude = FALSE	//if TRUE dont return files matching filter else return files that do
								);



